// BWCursor.m -- manage the custom cursors for the StitchNotator application

#import "BWCursor.h"

// singleton variables holding the cursors.  Loaded on demand.
static NSCursor *g_crosshairCursor;
static NSCursor *g_topLeftCursor;
static NSCursor *g_bottomRightCursor;


@implementation BWCursor


// get the crosshair cursor image from the bundle and make a cursor
// out of it

+ (NSCursor *) crosshairCursor
{
    if (g_crosshairCursor == nil) {

        NSImage *crosshairImage;
        crosshairImage = [NSImage imageNamed: @"crosshair"];

        if (crosshairImage == nil) {
            NSLog (@"could not load crosshair cursor image");
        } else {
            g_crosshairCursor = [[NSCursor alloc] 
                                    initWithImage: crosshairImage
                                    hotSpot: NSMakePoint (8, 8)];
        }
    }
    
    return (g_crosshairCursor);

} // crosshairCursor



// get the upper-left cursor image (looks like a framer's corner sample) 
// from the bundle and make a cursor out of it

+ (NSCursor *) upperLeftCursor
{
    if (g_topLeftCursor == nil) {

        NSImage *topLeftImage;
        topLeftImage = [NSImage imageNamed: @"upper-left"];

        if (topLeftImage == nil) {
            NSLog (@"could not load topLeft cursor image");
        } else {
            g_topLeftCursor = [[NSCursor alloc] 
                                  initWithImage: topLeftImage
                                  hotSpot: NSMakePoint (0, 0)];
        }
    }
    
    return (g_topLeftCursor);

} // upperLeftCursor



// get the bottom-Right cursor image (looks like a framer's corner sample,
// or a backwards 'L') from the bundle and make a cursor out of it

+ (NSCursor *) bottomRightCursor
{
    if (g_bottomRightCursor == nil) {

        NSImage *bottomRightImage;
        bottomRightImage = [NSImage imageNamed: @"bottom-right"];

        if (bottomRightImage == nil) {
            NSLog (@"could not load bottomRight cursorimage");
        } else {
            g_bottomRightCursor = [[NSCursor alloc] 
                                      initWithImage: bottomRightImage
                                      hotSpot: NSMakePoint (15, 15)];
        }
    }
    
    return (g_bottomRightCursor);

} // bottomRightCursor


@end // BWCursor

